package com.fy.restfulapi.constant;

/**
 * @author sunlei
 */
public enum CommonErrorCode implements StatusCode {

    // 常发生的HTTP状态码
    SUCCESS(true, 200, "请求成功"),
    FAIL(false,400, "请求失败"),
    UNAUTHORIZED(false,401, "未认证（签名错误）"),
    FORBIDDEN(false,403, "资源拒绝访问"),
    NOT_FOUND(false,404, "哎呀，无法找到这个资源啦"),
    METHOD_NOT_ALLOWED(false,405, "请换个姿势操作试试"),
    UNSUPPORTED_MEDIA_TYPE(false,415, "呀，不支持该媒体类型"),
    INTERNAL_SERVER_ERROR(false,500, "服务器开小差，请稍后再试"),

    /**
     * 空指针异常
     */
    NULL_POINT(false,2001, "空指针异常"),

    /**
     * 参数错误（参数校验）
     */
    PARAM_ERROR(false,2002, "参数错误"),

    /**
     * 系统限流
     */
    TRAFFIC_LIMITING(false,2003, "哎呀，网络拥挤请稍后再试试"),

    /**
     * 服务调用异常
     */
    API_GATEWAY_ERROR(false,2004, "网络繁忙，请稍后再试"),

    /**
     * 没有权限访问
     */
    NOT_PERMISSIONS(false,2005, "没有权限访问"),

    /**
     * 业务异常
     */
    BUSINESS_ERROR(false,2006, "业务异常"),

    /**
     * 未知异常
     */
    UNKNOWN_ERROR(false,9999, "未知异常");


    private Boolean success;
    private Integer code;
    private String message;

    // constructor
    CommonErrorCode(Boolean success, Integer code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    // getter
    @Override
    public Boolean getSuccess() {
        return success;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
